#include <stdio.h>

int main(int argc, char *argv[]) {

    for (size_t i = 95860; i < 100000; i++)
    {
        int g = i % 10;
        int s = i / 10 % 10;
        int q = i / 1000 % 10;
        int w = i / 10000 % 10;

        if(g==w&s==q){
            printf("%lld\n", i);
            break;
        }
            
    }
    


    return 0;
}